package cn.wolfcode.luowowo.mgrsite.web.controller;

import cn.wolfcode.luowowo.article.domain.TravelContent;
import cn.wolfcode.luowowo.article.query.TravelQuery;
import cn.wolfcode.luowowo.article.service.ITravelService;
import cn.wolfcode.luowowo.common.util.AJaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("travel")
public class TravelController {
    @Reference
    private ITravelService travelService;

    @RequestMapping("list")
    public String list(@ModelAttribute("qo") TravelQuery qo, Model model){
        PageInfo pageInfo = travelService.query(qo);
        model.addAttribute("pageInfo", pageInfo);
        return "travel/list";
    }

    @RequestMapping("updateState")
    @ResponseBody
    public AJaxResult updateState(Long id, Integer state){
        travelService.updateState(id, state);
        return AJaxResult.SUCCESS();
    }

    @RequestMapping("getContent")
    @ResponseBody
    public TravelContent getContent(Long id){
        return travelService.getContent(id);
    }
}
